package org.yak.core.store;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.session.RowBounds;
import org.yak.core.bean.DBSqlEntity;
import org.yak.core.provider.ProviderSqlParam;
import org.yak.core.provider.SqlProvider;
import org.yak.core.web.ResultSet;

/**
 * 基础Dao接口
 * @author zhouyang
 * @date 2014年3月3日下午1:02:16
 */
public interface IBaseStore<T extends Identifiable> {

	/**
	 * 查询业务模型数据返回分页的List集合对象
	 * @param sqlPrivider
	 * @param rowBounds
	 * @return
	 */
	@SelectProvider(type=SqlProvider.class, method = "selectTableDataSqlProvider")
	public <K, V> List<Map<K, V>> selectListTableMeta(ProviderSqlParam sqlPrivider,RowBounds rowBounds);
	
	/**
	 * 查询业务模型数据返回分页的List<ResultSet>集合对象
	 * @param sqlPrivider
	 * @param rowBounds
	 * @return
	 */
	@SelectProvider(type=SqlProvider.class, method = "selectTableDataSqlProvider")
	public List<ResultSet> selectListTableMetaResultSet(ProviderSqlParam sqlPrivider,RowBounds rowBounds);
	
	/**
	 * 查询业务模型返回Map集合对象
	 * @param sqlPrivider
	 * @return
	 */
	@SelectProvider(type=SqlProvider.class, method = "selectTableDataSqlProvider")
	public <K, V> Map<K, V> selectTableMeta(ProviderSqlParam sqlPrivider);
	
	/**
	 * 查询业务模型返回ResultSet集合对象
	 * @param sqlPrivider
	 * @return
	 */
	@SelectProvider(type=SqlProvider.class, method = "selectTableDataSqlProvider")
	public ResultSet selectTableMetaResultSet(ProviderSqlParam sqlPrivider);
	
	/**
	 * 查询业务模型返回ResultSet集合对象
	 * @param sqlPrivider
	 * @return
	 */
	@SelectProvider(type=SqlProvider.class, method = "selectTableDataSqlProvider")
	public List<ResultSet> selectTableMetaResultSetList(ProviderSqlParam sqlPrivider);
	
	/**
	 * 插入
	 * @param sqlPrivider
	 * @return
	 */
	@InsertProvider(type=SqlProvider.class, method = "insertTableDataSqlProvider")
	public int insertTableMeta(ProviderSqlParam sqlPrivider);
	
	/**
	 * 更新
	 * @param sqlPrivider
	 * @return
	 */
	@UpdateProvider(type=SqlProvider.class, method = "updateTableDataSqlProvider")
	public int updateTableMeta(ProviderSqlParam sqlPrivider);
	
	/**
	 * 删除
	 * @param sqlPrivider
	 * @return
	 */
	@DeleteProvider(type=SqlProvider.class, method = "deleteTableDataSqlProvider")
	public int deleteTableMeta(ProviderSqlParam sqlPrivider);
	
	/**
	 * 查询
	 * @方法没描述：
	 * @author XQ
	 * @param param
	 * @return
	 * @throws Exception
	 */
	@Select("${sql}")
	public Map<String,Object> selectMapBySql(DBSqlEntity sqlParam)throws Exception;
	
	/**
	 * 查询记录总数
	 * @param sqlParam
	 * @return
	 * @throws Exception
	 */
	@Select("${sql}")
	public int selectCountBySql(DBSqlEntity sqlParam)throws Exception;
	
	/**
	 * 查询
	 * @方法没描述：
	 * @author XQ
	 * @param param
	 * @return
	 * @throws Exception
	 */
	@Select("${sql}")
	public List<Map<String,Object>> selectMapListBySql(DBSqlEntity sqlParam)throws Exception;
	
	/**
	 * 查询
	 * @方法没描述：
	 * @author XQ
	 * @param param
	 * @return
	 * @throws Exception
	 */
	@Select("${sql}")
	public ResultSet selectResultSetBySql(DBSqlEntity sqlParam)throws Exception;
	
	/**
	 * 
	 * @param sqlParam
	 * @return
	 * @throws Exception
	 */
	@Select("${sql}")
	public List<ResultSet> selectResultSetListBySql(DBSqlEntity sqlParam)throws Exception;
	
	/**
	 * 动态插入sql
	 * @方法没描述：
	 * @author XQ
	 * @param sql
	 * @throws Exception
	 */
	@Insert("${sql}")
	public void insertTableBySql(DBSqlEntity sqlParam)throws Exception;

	/**
	 * 更新
	 * @方法没描述：
	 * @author XQ
	 * @param param
	 * @throws Exception
	 */
	@Insert("${sql}")
	public int updateTableBySql(DBSqlEntity sqlParam)throws Exception;
}
